package com.sc.ifs.goods;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sc.dal.model.goods.GoodsHotwords;
import com.sc.service.goods.GoodsHotwordsService;
import com.sc.util.data.DataUtil;
import com.sc.util.exception.ExceptionEnum;


/**
 * 商品热门词汇管理
 * @author maoyongbin
 * @日期 Mar 13, 2017 10:22:35 AM
 */
@Controller
@RequestMapping(value="app/goodsHotwords")
public class GoodsHotwordsController {
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private GoodsHotwordsService goodsHotwordsService;
	
	/**
	 * 查找所有商品热门词汇
	 * @return Map<String, Object>
	 */
	@RequestMapping(value="/selectList", method=RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> selectList() {
		Map<String, Object> resultMap = new LinkedHashMap<String,Object>();
		try{
			List<GoodsHotwords> goodsHotwordsList = this.goodsHotwordsService.select();
			if(goodsHotwordsList!=null && goodsHotwordsList.size()>0){
				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
				resultMap.put("data", this.goodsHotwordsService.getGoodsHotwordsData(goodsHotwordsList));
				logger.warn("查找所有商品热门词汇成功！");
			}else{
				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SELECT);
				logger.warn("查找所有商品热门词汇失败！");
			}
		}catch (Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SELECT);
			logger.warn("查找所有商品热门词汇出错！");
		}
		
		return resultMap;
	}
}
